import { StateCreator } from "zustand";
import { StoreState } from ".";

export interface BearSlice {
  bears: number;
  addBear: () => void;
  eatBear: () => void;
}

type CreateBearSlice = StateCreator<StoreState, [], [], BearSlice>;

export const initialBearState = {
  bears: 0,
};

export const createBearSlice: CreateBearSlice = (set) => {
  return {
    ...initialBearState,
    addBear: () => set((state) => ({ bears: state.bears + 1 })),
    eatBear: () => set((state) => ({ bears: state.bears - 1 })),
  };
};
